package com.ch06.ex04;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;

import java.nio.charset.Charset;

/**
 * Created by zc on 2016/3/16.
 */
public class SlicedMain {

    public static void main(String[] args){
        Charset utf8 = Charset.forName("UTF-8");
        ByteBuf buf = Unpooled.copiedBuffer("Netty in Action rocks!", utf8);

        ByteBuf sliced = buf.slice(0, 14);
        System.out.println(sliced.toString(utf8));

        buf.setByte(0, (byte)'J');

        boolean rs = buf.getByte(0) == sliced.getByte(0);

        System.out.println(rs);

    }
}
